package haw.pr2.A3.implementations;

import com.sun.org.apache.xpath.internal.operations.Equals;
import haw.pr2.A3.interfaces.Pallet;
import haw.pr2.A3.interfaces.UniqueId;
import haw.pr2.A3.interfaces.BoundingBox;
import haw.pr2.A3.interfaces.Location;
import haw.pr2.A3.interfaces.Mass;
import haw.pr2.A3.interfaces.Pallet;
import haw.pr2.A3.interfaces.Stowage;
import haw.pr2.A3.interfaces.StowageLocation;
import static haw.pr2.A3.implementations.UtilityclassValues.*;
import static haw.pr2.A3.implementations.Entities.*;


/**
 *
 * @author Fabian Heidorn, Alexander Kaack
 */
abstract class AbstractPallet implements Pallet {
       
    UniqueId id = UniqueIdImpl.getNextID();
    Mass mass;
    StowageLocation loc;
    Stowage myStowage;
    BoundingBox bBox;
    
    
    @Override
    public Mass mass() {
        return this.mass;
    }

    @Override
    public BoundingBox boundingBox() {
        return bBox;
    }

    @Override
    public int compareTo(Pallet o) {
        return this.id.compareTo(o.UniqueId());
    }

    @Override
    public Location loc() {
        return loc;
    }

    @Override
    public void setLocNull() {
        loc = nullLocation();
        this.myStowage=Entities.palletsStowage();
    }

    @Override
    public void setLoc(Stowage stowage, StowageLocation loc) {
        this.loc = loc;
        this.myStowage=stowage;
    }

    @Override
    public UniqueId UniqueId() {
        return this.id;
    }

    
    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof Pallet)) return false;
        return this.compareTo((Pallet)obj) == 0;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 23 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
    
 
}
